<?

/********************************************
* notifications.php
*
* This page allows users to configure notifications to send to their cell phones via SMS or email.
********************************************/

//include files
include "db.php";
include "tbatv_lib.php";

$title = " - Notifications";
include "header.php";

if ($_GET)
{

//are we deleting?
if (sanatizeGet($_GET['action']) == 'delete')
{
	//get the notification ID and delete it
	$id = sanatizeGet($_GET['notifid']);
	mysql_query("DELETE FROM notifications WHERE notificationid = {$id}");
	echo "<h1>Notification Deleted</h1><p>This notification has been deleted. Please click <a href=\"#\" onclick=\"browser.back();\">here</a> to return to the previous page.</p>";
}

if (sanatizeGet($_GET['action']) == 'add')
{
	//we are adding a notification for this user.
	
	//get notification mode and ID (either teamnumber or eventid)
	$mode = sanatizeGet($_GET['mode']);
	$id = sanatizeGet($_GET['id']);
	
	//perform mysql insert
	mysql_query("INSERT INTO notifications(user, mode, id) VALUES({$user}, {$mode}, {$id})") or die(mysql_error());
	echo "<h1>Notification Added</h1><p>This {$mode} notification was successfully added. Please click <a href=\"#\" onclick=\"browser.back();\">here</a> to return to the previous page.</p>";
}

}

include "footer.php";
?>